feat: Graph tracking refactor — ManagedAgentGraph drives tracking for new runner shape#154
Merged
jsonbailey merged 7 commits intomainfrom May 4, 2026
Merged
Conversation
cbe2eda to
4f12618
Compare
fcbcb18 to
9286d53
Compare
4f12618 to
351f249
Compare
9286d53 to
72fc13e
Compare
351f249 to
ef03235
Compare
72fc13e to
bde4f09
Compare
ef03235 to
e5ecc6a
Compare
bde4f09 to
c376011
Compare
e5ecc6a to
1636446
Compare
c376011 to
7f67e4f
Compare
1636446 to
0fae2df
Compare
7f67e4f to
a89c6a2
Compare
0fae2df to
a468a7f
Compare
c69a9ff to
14cfa92
Compare
0a1ee15 to
72f5a37
Compare
14cfa92 to
1ed1a44
Compare
72f5a37 to
8e60f79
Compare
1ed1a44 to
f016b0d
Compare
f9e947b to
75172d8
Compare
76b9580 to
7f0642e
Compare
… new runner shape ManagedAgentGraph.run() now detects the runner result type and dispatches accordingly: - AgentGraphRunnerResult (new shape): managed layer drives all graph-level tracking from result.metrics (path, duration, success/failure, total tokens) via the graph tracker. Node-level tracking from node_metrics will be wired once runners populate that field (PR 11-openai/langchain). - AgentGraphResult (legacy shape): tracking already occurred inside the runner; managed layer wraps result without additional tracking. ManagedAgentGraph now accepts an optional graph parameter (AgentGraphDefinition) used to create the graph tracker. LDAIClient.create_agent_graph() passes the resolved graph definition. This is a deliberate bridge pattern: the legacy detection branch will be removed once both runners are migrated. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ManagedAgentGraph now expects AgentGraphRunnerResult (with GraphMetrics) from all runners and drives graph-level and per-node LD tracking from result.metrics. AgentGraphRunner protocol updated to return AgentGraphRunnerResult. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Aligns ManagedAgentGraph constructor with the ManagedModel and ManagedAgent pattern: graph (AgentGraphDefinition) is now the first required parameter, followed by the runner. Removes the Optional guard and tightens the type annotation accordingly. Updates client.py call site and all test fixtures. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
5527667 to
8035890
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8035890. Configure here.
keelerm84
approved these changes
May 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Moves graph-level LaunchDarkly tracking from inside the runner implementations to the
ManagedAgentGraphmanaged layer.ManagedAgentGraph.run()now detects runner result type viaisinstance:AgentGraphRunnerResult(new shape): managed layer drives all graph-level tracking (path, duration, success/failure, total tokens) fromresult.metricsvia the graph trackerAgentGraphResult(legacy shape): tracking already occurred inside the runner; managed layer wraps the result without additional trackingManagedAgentGraphnow accepts an optionalgraph: AgentGraphDefinitionparameter used to create the graph trackerLDAIClient.create_agent_graph()passes the resolved graph definition asgraph=graphDeliberate bridge pattern: The legacy detection branch exists because PR 11-openai and PR 11-langchain have not yet migrated their runners to return
AgentGraphRunnerResult. Once both runners are migrated, the legacyAgentGraphResultbranch becomes dead code and will be removed in PR 11-langchain's cleanup commit.Depends on
Test plan
uv run pytest packages/sdk/server-ai/tests/)test_managed_agent_graph_run_handles_new_shape,test_managed_agent_graph_new_shape_drives_tracking,test_managed_agent_graph_new_shape_no_graph_skips_tracking🤖 Generated with Claude Code
Note
Medium Risk
Changes the
AgentGraphRunner.run()return type and refactors graph/node metric tracking, which may break provider implementations or alter emitted analytics events if any callers still rely on the legacy shapes/semantics.Overview
Refactors agent-graph execution so
ManagedAgentGraphnow owns graph-level and per-node LaunchDarkly tracking, driven from the runner’s returnedGraphMetrics(path/duration/success/token usage plus node metrics) instead of relying on provider-specific runner implementations.Updates the public runner interface to return
AgentGraphRunnerResult(withcontent+GraphMetrics), adjustsGraphMetricSummaryto hold per-nodeLDAIMetricSummaryvalues, and changes tool-call tracking summaries to accumulate calls rather than being single-assignment.Adds/updates tests around the new managed tracking behavior and includes a new
poetry.lockforserver-ai.Reviewed by Cursor Bugbot for commit 7515637. Bugbot is set up for automated code reviews on this repo. Configure here.